SOURCES = glib/glist.c glib/ghash.c bfs.c node.c edge.c network.c parser.c bfsNet.c
LPAR = \(
RPAR = \)
TARGET := $(shell egrep -l '^[^/]*int[[:space:]]*main[[:space:]]*$(LPAR)[^$(RPAR)]*$(RPAR)' $(SOURCES))
TARGET := $(TARGET:%.c=%)
HEADERS = glib/gtypes.h glib/gmacros.h glib/glist.h glib/ghash.h bfsnet.h network.h bfs.h node.h edge.h parser.h 
OBJECTS = $(SOURCES:.c=.o)

.PHONY : clean dist

#LIBS = -lefence
CC = gcc
CFLAGS = -g -Wall -pedantic \
-ansi \
-Waggregate-return \
-Wbad-function-cast \
-Wcast-align \
-Wdeclaration-after-statement \
-Wendif-labels \
-Werror \
-Wextra \
-Wfloat-equal \
-Wimport \
-Winline \
-Winvalid-pch \
-Wlong-long \
-Wmissing-declarations \
-Wmissing-field-initializers \
-Wmissing-format-attribute \
-Wmissing-prototypes \
-Wnested-externs \
-Wold-style-definition \
-Wpacked \
-Wpointer-arith \
-Wpointer-sign \
-Wredundant-decls \
-Wshadow \
-Wsign-compare \
-Wstrict-prototypes \
-Wundef \
-Wunreachable-code \
-Wunused-macros \
-Wvariadic-macros \
-Wwrite-strings\
-Wformat \
-DNDEBUG # Desactivar si se quiere usar assert

all: $(TARGET)

clean:
	rm -f $(TARGET) $(OBJECTS) .depend 

distclean:
	rm -f $(TARGET) $(OBJECTS) .depend *~ *.tgz

-include .depend

.depend: $(SOURCES) $(HEADERS)
	gcc -MM $(SOURCES) $(HEADERS) >.depend


$(TARGET): $(OBJECTS)
	$(CC) -o $@ $(OBJECTS) $(CFLAGS) $(LIBS)

dist: clean
	tar -czvf $(TARGET).tgz *.c *.h

